# 定义容器ID
CONTAINER_ID=0b4187759080


# 这是在把Inputs文件复制到容器里面指定的位置
cd /usr/local/itf/

# 复制 Inputs 目录到 Docker 容器的根目录
docker cp 45555/* "$CONTAINER_ID":/Inputs/

docker cp /usr/local/itf/shell/runmodel.sh "$CONTAINER_ID":/ITF_v204_GPU_Codes_220216/

echo "Files from /Inputs have been copied to the Docker container ($CONTAINER_ID)."


# 使用docker exec在容器中执行命令
docker exec -it "$CONTAINER_ID" bash -c '\
    cd ITF_v204_GPU_Codes_220216 \
    && chmod -R +rw /Inputs/* \
    && chmod +x runmodel.sh \
    && ./runmodel.sh \
    && until [ -n "$(ls -A ../Outputs)" ]; do sleep 5; done \
    && echo "Files found in Outputs directory, waiting for an additional 20 seconds..." \
    && sleep 2 \
    && echo "Model execution and waiting period finished." \
    && exit
'

# 在主脚本中添加，确保即使docker exec命令的输出被抑制，也能看到完成信息
echo "Script execution completed."

rm -rf /usr/local/itf/Outputs

rm -rf /home/siyu-grpc/cfdata/resultgeo/*
# 将容器内的/Outputs目录复制到主机当前目录
docker cp "$CONTAINER_ID":/Outputs /usr/local/itf/
echo "Outputs directory has been copied to the host."

# 再次进入容器并执行清理操作
docker exec -it "$CONTAINER_ID" bash -c '\
    rm -rf Outputs/* \
    && rm -rf Inputs/* \
    && echo "Cleanup completed. Outputs directory removed inside the container." \
    && exit
'
echo "Cleanup operation executed in the container."

